unit Unit5;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, IniFiles;

type
  TForm5 = class(TForm)
    GroupBox1: TGroupBox;
    Edit1: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Button1: TButton;
    Button2: TButton;
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }   
    function CorrectSUID:BOOL;
  end;

var
  Form5: TForm5;

implementation

uses Unit1;

{$R *.dfm}

procedure TForm5.Button2Click(Sender: TObject);
begin
  close;
end;

function PolitCorrect(S:String):BOOL;
var
  i:integer;
  j:integer;
const
  censore = 'QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm1234567890.';
begin
  result:=false;
  if length(s)=0 then exit;
  for i:=0 to length(s) do
  begin
    result:=false;
    for j:=0 to length(censore) do
      if S[i]=censore[j] then
      begin
        result:=true;
        break;
      end;
    if not result then break;
  end;
end;

function TForm5.CorrectSUID: BOOL;
var
  Ini:TIniFile;
begin
  result:=false;
  if not FileExists(ExtractFilePath(paramstr(0))+'servers.ini') then exit;
  Ini:=TINIFile.Create(ExtractFilePath(paramstr(0))+'servers.ini');
  result:=PolitCorrect(Ini.ReadString('server0','SUID',''));
  Ini.Free;
end;

procedure Renew;
var
  Ini:TIniFile;
begin
  Ini:=TINIFile.Create(ExtractFilePath(paramstr(0))+'servers.ini');
  Form5.Edit1.Text:=Ini.ReadString('server0','SUID','');
  Ini.Free;
end;

procedure TForm5.Button1Click(Sender: TObject);
var
  Ini:TIniFile;
begin
  if not PolitCorrect(Edit1.Text) then
  begin
    Showmessage('Use please only letters, numbers and point symbol');
    Renew;
    exit;
  end;
  Ini:=TINIFile.Create(ExtractFilePath(paramstr(0))+'servers.ini');
  Ini.WriteString('server0','SUID',Edit1.Text);
  Ini.Free;    
  Renew;
end;

procedure TForm5.FormShow(Sender: TObject);
begin
  Renew;
end;

end.
